"""
策略
"""
import random


class CONFIG:
    def __init__(self):
        self.min = 39
        self.max = 59
        self.big = 52
        self.small = 47


class HASH:
    def get_10000_num(self):
        """
        获取10000条数据，取其中1000条，每隔10个一条
        :return:
        """
        arr_num = []
        for i in range(0, 10000):
            int_random = self.get_random()
            if i % 10 == 0:
                arr_num.append({
                    "id": i,
                    "num": int_random
                })
        return arr_num

    def get_random(self):
        """
        获取随机数
        :return:
        """
        return random.randint(0, 99)

    def get_recent_100(self, num):
        """
        获取最近间隔num个块的数据
        :param num:
        :return:
        """
        arr_all = self.get_10000_num()
        arr_20_num = list(filter(lambda x: x["id"] % num == 0, arr_all))
        return {
            "num": num,
            "dit": arr_20_num[-100:]
        }

    def get_num_percent_in_recent_100(self, type, num):
        """
        获取大于或小于num占100个里面的比例
        :param type:
        :param num:
        :return:
        """
        config = CONFIG()
        arr_all_num = []
        for i in [10, 20, 30, 40, 50, 60, 70, 80, 90]:
            arr_num = []
            arr_list_num = self.get_recent_100(i)
            for v in arr_list_num["dit"]:
                if v["num"] > num:
                    arr_num.append(v)
            arr_all_num.append({
                "type": type,
                "len": len(arr_num)
            })
        return arr_all_num

    def get_recent_big_or_small_num(self):
        """
        核心处理模块
        :return:
        """
        arr_all_num = []
        for i in [10, 20, 30, 40, 50, 60, 70, 80, 90]:
            arr_all_num.append(self.get_recent_100(i))
        return arr_all_num



